﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChessTest.Chess.Items
{
    [Serializable]
    class MandarinsItem : Chessman
    {
        public override string DisplayName => "士";


        public override bool CanOriginMove(Chessboard chessboard,int selectX, int selectY)
        {
            if (!base.CanOriginMove(chessboard,selectX, selectY)) return false;
            if (Math.Abs(selectX - PositionX) != 1 || Math.Abs(selectY - PositionY) != 1)
                return false;
            return true;
        }


        protected override bool IsOverstep(Chessboard chessboard,int x, int y)
        {
            //是否越界
            if (x > 5 || x < 3)
                return true;

            if (PositionY < 3 && (y >= 3 || y < 0))
                return true;
            if (PositionY > 6 && (y <= 6 || y >= chessboard.MaxY))
                return true;
            return false;
        }


        public override List<Point> GetOriginCanMoveList(Chessboard chessboard)
        {
            List<Point> list = new List<Point>();
            if (CanOriginMove(chessboard,PositionX + 1, PositionY + 1))
                list.Add(new Point(PositionX + 1, PositionY + 1));
            if (CanOriginMove(chessboard,PositionX - 1, PositionY + 1))
                list.Add(new Point(PositionX - 1, PositionY + 1));
            if (CanOriginMove(chessboard,PositionX + 1, PositionY - 1))
                list.Add(new Point(PositionX + 1, PositionY - 1));
            if (CanOriginMove(chessboard,PositionX - 1, PositionY - 1))
                list.Add(new Point(PositionX - 1, PositionY - 1));
            return list;
        }

        public override int Score
        {
            get
            {
                return 3;
            }
        }
    }
}
